/*
package com.lazy.utils.redis;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.Assert;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream;

*/
/**
 * @author: wql
 * @create_time: 2018-02-06 14:57
 * @describe: redis
 *//*

@Configuration
public class JedisClusterConfig {


    @Value("${redis.default.hosts}")
    private String[] hosts;
    @Value("${redis.default.password}")
    private String password;
    @Value("${redis.default.maxTotal}")
    private int maxTotal;
    @Value("${redis.default.maxWaitMillis}")
    private long maxWaitMillis;
    @Value("${redis.default.maxIdle}")
    private int maxIdle;
    @Value("${redis.default.minIdle}")
    private int minIdle;
    @Value("${redis.default.testOnBorrow}")
    private boolean testOnBorrow;
    @Value("${redis.default.connectionTimeout}")
    private int connectionTimeout;
    @Value("${redis.default.soTimeout}")
    private int soTimeout;
    @Value("${redis.default.maxAttempts}")
    private int maxAttempts;

    */
/**
     * 一、JedisPoolConfig 即使传入，JedisCluster初始化也不采用，毫无意义
     * 二、JedisCluster 自动关闭池连接，不用每次调用都关闭
     * 三、只要服务停止，就可以调用close 关闭集群连接即可
     *
     * @return
     *//*

    @Bean(destroyMethod = "close")
    public JedisCluster redisCluster() {
        Set<HostAndPort> nodes = new HashSet<>();
        Stream.of(hosts).forEach((host) -> {
            String[] parts = StringUtils.split(host, ":");
            Assert.state(parts.length == 2, "redis node should be defined as 'host:port', not '" + Arrays.toString(parts) + "'");
            nodes.add(new HostAndPort(parts[0], Integer.valueOf(parts[1])));
        });
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxIdle(maxIdle);
        jedisPoolConfig.setMaxTotal(maxTotal);
        jedisPoolConfig.setMinIdle(minIdle);
        jedisPoolConfig.setTestOnBorrow(testOnBorrow);
        if (StringUtils.isBlank(password)) {
            password = null;
        }
        return new JedisCluster(nodes, connectionTimeout, soTimeout, maxAttempts, password, jedisPoolConfig);
    }

}
*/
